package company.beike;

import java.util.List;
import java.util.Scanner;

public class BeiKe2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] result = new int[count];
        for (int i = 0; i < count; i++) {
            int m = sc.nextInt();
            int n = sc.nextInt();
            if (m % 2 == 0 || n % 2 == 0)
                System.out.println(2);
            else {
                System.out.println(3);
//                int tmp = 3;
//                int min = Math.min(m, n);
//                while (min % tmp != 0)
//                    tmp++;
//                result[i] = tmp;
            }

        }
//        for (int i = 0; i < count; i++) {
//            System.out.println(result[i]);
//        }
    }
}
